import Vue from 'vue'
import VueRouter from 'vue-router'
import Layout from '@/views/layout'
const originalPush = VueRouter.prototype.push
 
VueRouter.prototype.push = function push(location) {
  return originalPush.call(this, location).catch(err => err)
}
Vue.use(VueRouter)

const routes = [
  {
    path: '/login',
    name: 'login',
    component: () => import('@/views/login')
  },
  {
    path: '/',
    name: 'redirect',
    redirect: '/home',
    component: Layout,
    children: [
      {
        path: 'home',
        name: 'home',
        component: () => import('@/views/home')
      },
      {
        path: 'project',
        name: 'project',
        component: () => import('@/views/project')
      },
      {
        path: 'cust',
        name: 'cust',
        component: () => import('@/views/cust')
      },
      {
        path: 'prod',
        name: 'prod',
        component: () => import('@/views/prod')
      },
      {
        path: 'user',
        name: 'user',
        component: () => import('@/views/user')
      },
      {
        path: 'standard',
        name: 'standard',
        component: () => import('@/views/standard')
      },
      {
        path: 'trade',
        name: 'trade',
        component: () => import('@/views/trade')
      },
      {
        path: 'task',
        name: 'task',
        component: () => import('@/views/task')
      },
      {
        path: 'credit',
        name: 'credit',
        component: () => import('@/views/credit')
      },
      {
        path: 'price',
        name: 'price',
        component: () => import('@/views/price')
      },
    ]
  },
  {
    path: '/account',
    name: 'account',
    component: Layout,
    children: [
      {
        path: 'list',
        name: 'accountList',
        component: () => import('@/views/account')
      },
      {
        path: 'check',
        name: 'accountCheck',
        component: () => import('@/views/account/checkList')
      },
      {
        path: 'pay',
        name: 'payList',
        component: () => import('@/views/account/payList')
      }
    ]
  },
  {
    path: '/stat',
    name: 'stat',
    component: Layout,
    children: [
      {
        path: 'trade',
        name: 'tradeStat',
        component: () => import('@/views/stat/tradeStat')
      }
    ]
  }
]

const router = new VueRouter({
  routes
})

export default router
